-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configure log timestamp format #5050
Configure log timestamp format #5050
Conversation
a1539d4
to
8ca7a50
Compare
@SVilgelm thanks for the contribution. It would be great if you could add some unit tests. Thanks. |
I would be glad to do it, but need some hints. What do you think is the best place for testing new cli argument? I did not find any tests for the log-format or log-level args |
I would have imagined a simple test which collects the log output with the |
@SVilgelm You might be able to build off of the existing end-to-end logging tests. I think there's at least one test case there that checks to make sure the decision log JSON has the correct keys present-- that can almost certainly be upgraded into a check for the timestamp matching a regex for a custom format. |
@ashutosh-narkar @philipaconrad I added the additional unit test in |
5369ba3
to
e73cd05
Compare
let user to configure the log's timestamp format by: * cli argument `log-timestamp-format` * environment variable `OPA_LOG_TIMESTAMP_FORMAT` Closes open-policy-agent#2413 Signed-off-by: Sergey Vilgelm <[email protected]>
Signed-off-by: Sergey Vilgelm <[email protected]>
e73cd05
to
b5872f9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
checkLogTimeStampFormat(t, params, format) | ||
}) | ||
t.Run("environment variable", func(t *testing.T) { | ||
t.Setenv("OPA_LOG_TIMESTAMP_FORMAT", format) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neat. I didn't know that function. Pretty handy. https://pkg.go.dev/testing#T.Setenv
let user to configure the log's timestamp format by:
log-timestamp-format
OPA_LOG_TIMESTAMP_FORMAT
Closes #2413
Signed-off-by: Sergey Vilgelm [email protected]